project(asio_unit_test)

function(mytest TARGET DIR)
    set(cppnames "" PARENT_SCOPE)
    foreach(cppname ${ARGN})
        # message("append: " ${cppname})
        list(APPEND cppnames ${DIR}/${cppname})
    endforeach()
    # message("cppnames: " ${cppnames})

    add_executable(${TARGET} ${cppnames})
    set_target_properties(${TARGET}
        PROPERTIES
        RUNTIME_OUTPUT_DIRECTORY ${DIR}
    )

    if (ASIO_DYN_LINK)
        target_link_libraries(${TARGET}
            PRIVATE
            asio        
        )
    else (ASIO_DYN_LINK)
        target_include_directories(${TARGET}
            PRIVATE
            ${CMAKE_SOURCE_DIR}/include
        )
        if (UNIX)
                target_link_libraries(${TARGET}
                        PRIVATE
                        pthread
                )
        endif (UNIX)
    endif (ASIO_DYN_LINK)
    add_test(
        NAME ${TARGET}
        COMMAND ${TARGET}
    )
endfunction(mytest DIR TARGET)

# if !STANDALONE
# mytest(latency_tcp_clientg latency tcp_client.cpp)
# mytest(latency_tcp_serverg latency tcp_server.cpp)
# mytest(latency_udp_clientg latency udp_client.cpp)
# mytest(latency_udp_serverg latency udp_server.cpp)
# mytest(performance_clientg performance client.cpp)
# mytest(performance_serverg performance server.cpp)
# endif()
mytest(unit_appendg unit append.cpp)
mytest(unit_as_tupleg unit as_tuple.cpp)
mytest(unit_associated_allocatorg unit associated_allocator.cpp)
mytest(unit_associated_cancellation_slotg unit associated_cancellation_slot.cpp)
mytest(unit_associated_executorg unit associated_executor.cpp)
mytest(unit_associated_immediate_executorg unit associated_immediate_executor.cpp)
mytest(unit_associatorg unit associator.cpp)
mytest(unit_async_resultg unit async_result.cpp)
mytest(unit_awaitableg unit awaitable.cpp)
mytest(unit_basic_datagram_socketg unit basic_datagram_socket.cpp)
mytest(unit_basic_deadline_timerg unit basic_deadline_timer.cpp)
mytest(unit_basic_fileg unit basic_file.cpp)
mytest(unit_basic_random_access_fileg unit basic_random_access_file.cpp)
mytest(unit_basic_raw_socketg unit basic_raw_socket.cpp)
mytest(unit_basic_readable_pipeg unit basic_readable_pipe.cpp)
mytest(unit_basic_seq_packet_socketg unit basic_seq_packet_socket.cpp)
mytest(unit_basic_serial_portg unit basic_serial_port.cpp)
mytest(unit_basic_signal_setg unit basic_signal_set.cpp)
mytest(unit_basic_socketg unit basic_socket.cpp)
mytest(unit_basic_socket_acceptorg unit basic_socket_acceptor.cpp)
mytest(unit_basic_stream_fileg unit basic_stream_file.cpp)
mytest(unit_basic_stream_socketg unit basic_stream_socket.cpp)
mytest(unit_basic_streambufg unit basic_streambuf.cpp)
mytest(unit_basic_waitable_timerg unit basic_waitable_timer.cpp)
mytest(unit_basic_writable_pipeg unit basic_writable_pipe.cpp)
mytest(unit_bind_allocatorg unit bind_allocator.cpp)
mytest(unit_bind_cancellation_slotg unit bind_cancellation_slot.cpp)
mytest(unit_bind_executorg unit bind_executor.cpp)
mytest(unit_bind_immediate_executorg unit bind_immediate_executor.cpp)
mytest(unit_bufferg unit buffer.cpp)
mytest(unit_buffer_registrationg unit buffer_registration.cpp)
mytest(unit_buffers_iteratorg unit buffers_iterator.cpp)
mytest(unit_buffered_read_streamg unit buffered_read_stream.cpp)
mytest(unit_buffered_streamg unit buffered_stream.cpp)
mytest(unit_buffered_write_streamg unit buffered_write_stream.cpp)
mytest(unit_cancellation_signalg unit cancellation_signal.cpp)
mytest(unit_cancellation_stateg unit cancellation_state.cpp)
mytest(unit_cancellation_typeg unit cancellation_type.cpp)
mytest(unit_co_spawng unit co_spawn.cpp)
mytest(unit_completion_conditiong unit completion_condition.cpp)
mytest(unit_composeg unit compose.cpp)
mytest(unit_connectg unit connect.cpp)
mytest(unit_connect_pipeg unit connect_pipe.cpp)
mytest(unit_consigng unit consign.cpp)
mytest(unit_coroutineg unit coroutine.cpp)
mytest(unit_deadline_timerg unit deadline_timer.cpp)
mytest(unit_deferg unit defer.cpp)
mytest(unit_deferredg unit deferred.cpp)
mytest(unit_detachedg unit detached.cpp)
mytest(unit_dispatchg unit dispatch.cpp)
mytest(unit_errorg unit error.cpp)
mytest(unit_execution_any_executorg unit execution/any_executor.cpp)
mytest(unit_execution_blockingg unit execution/blocking.cpp)
mytest(unit_execution_blocking_adaptationg unit execution/blocking_adaptation.cpp)
mytest(unit_execution_bulk_executeg unit execution/bulk_execute.cpp)
mytest(unit_execution_bulk_guaranteeg unit execution/bulk_guarantee.cpp)
mytest(unit_execution_connectg unit execution/connect.cpp)
mytest(unit_execution_context_asg unit execution/context_as.cpp)
mytest(unit_execution_executeg unit execution/execute.cpp)
mytest(unit_execution_executorg unit execution/executor.cpp)
mytest(unit_execution_invocable_archetypeg unit execution/invocable_archetype.cpp)
mytest(unit_execution_mappingg unit execution/mapping.cpp)
mytest(unit_execution_outstanding_workg unit execution/outstanding_work.cpp)
mytest(unit_execution_operation_stateg unit execution/operation_state.cpp)
mytest(unit_execution_prefer_onlyg unit execution/prefer_only.cpp)
mytest(unit_execution_receiverg unit execution/receiver.cpp)
mytest(unit_execution_relationshipg unit execution/relationship.cpp)
mytest(unit_execution_scheduleg unit execution/schedule.cpp)
mytest(unit_execution_schedulerg unit execution/scheduler.cpp)
mytest(unit_execution_senderg unit execution/sender.cpp)
mytest(unit_execution_set_doneg unit execution/set_done.cpp)
mytest(unit_execution_set_errorg unit execution/set_error.cpp)
mytest(unit_execution_set_valueg unit execution/set_value.cpp)
mytest(unit_execution_startg unit execution/start.cpp)
mytest(unit_execution_submitg unit execution/submit.cpp)
mytest(unit_execution_contextg unit execution_context.cpp)
mytest(unit_executorg unit executor.cpp)
mytest(unit_executor_work_guardg unit executor_work_guard.cpp)
mytest(unit_file_baseg unit file_base.cpp)
mytest(unit_generic_basic_endpointg unit generic/basic_endpoint.cpp)
mytest(unit_generic_datagram_protocolg unit generic/datagram_protocol.cpp)
mytest(unit_generic_raw_protocolg unit generic/raw_protocol.cpp)
mytest(unit_generic_seq_packet_protocolg unit generic/seq_packet_protocol.cpp)
mytest(unit_generic_stream_protocolg unit generic/stream_protocol.cpp)
mytest(unit_high_resolution_timerg unit high_resolution_timer.cpp)
mytest(unit_io_contextg unit io_context.cpp)
mytest(unit_io_context_strandg unit io_context_strand.cpp)
mytest(unit_ip_addressg unit ip/address.cpp)
mytest(unit_ip_address_v4g unit ip/address_v4.cpp)
mytest(unit_ip_address_v4_iteratorg unit ip/address_v4_iterator.cpp)
mytest(unit_ip_address_v4_rangeg unit ip/address_v4_range.cpp)
mytest(unit_ip_address_v6g unit ip/address_v6.cpp)
mytest(unit_ip_address_v6_iteratorg unit ip/address_v6_iterator.cpp)
mytest(unit_ip_address_v6_rangeg unit ip/address_v6_range.cpp)
mytest(unit_ip_basic_endpointg unit ip/basic_endpoint.cpp)
mytest(unit_ip_basic_resolverg unit ip/basic_resolver.cpp)
mytest(unit_ip_basic_resolver_entryg unit ip/basic_resolver_entry.cpp)
mytest(unit_ip_basic_resolver_iteratorg unit ip/basic_resolver_iterator.cpp)
mytest(unit_ip_basic_resolver_queryg unit ip/basic_resolver_query.cpp)
mytest(unit_ip_host_nameg unit ip/host_name.cpp)
mytest(unit_ip_icmpg unit ip/icmp.cpp)
mytest(unit_ip_multicastg unit ip/multicast.cpp)
mytest(unit_ip_network_v4g unit ip/network_v4.cpp)
mytest(unit_ip_network_v6g unit ip/network_v6.cpp)
mytest(unit_ip_resolver_query_baseg unit ip/resolver_query_base.cpp)
mytest(unit_ip_tcpg unit ip/tcp.cpp)
mytest(unit_ip_udpg unit ip/udp.cpp)
mytest(unit_ip_unicastg unit ip/unicast.cpp)
mytest(unit_ip_v6_onlyg unit ip/v6_only.cpp)
mytest(unit_is_read_bufferedg unit is_read_buffered.cpp)
mytest(unit_is_write_bufferedg unit is_write_buffered.cpp)
mytest(unit_local_basic_endpointg unit local/basic_endpoint.cpp)
mytest(unit_local_connect_pairg unit local/connect_pair.cpp)
mytest(unit_local_datagram_protocolg unit local/datagram_protocol.cpp)
mytest(unit_local_seq_packet_protocolg unit local/seq_packet_protocol.cpp)
mytest(unit_local_stream_protocolg unit local/stream_protocol.cpp)
mytest(unit_packaged_taskg unit packaged_task.cpp)
mytest(unit_placeholdersg unit placeholders.cpp)
mytest(unit_posix_basic_descriptorg unit posix/basic_descriptor.cpp)
mytest(unit_posix_basic_stream_descriptorg unit posix/basic_stream_descriptor.cpp)
mytest(unit_posix_descriptorg unit posix/descriptor.cpp)
mytest(unit_posix_descriptor_baseg unit posix/descriptor_base.cpp)
mytest(unit_posix_stream_descriptorg unit posix/stream_descriptor.cpp)
mytest(unit_postg unit post.cpp)
mytest(unit_prependg unit prepend.cpp)
mytest(unit_random_access_fileg unit random_access_file.cpp)
mytest(unit_readg unit read.cpp)
mytest(unit_read_atg unit read_at.cpp)
mytest(unit_read_untilg unit read_until.cpp)
mytest(unit_readable_pipeg unit readable_pipe.cpp)
mytest(unit_recycling_allocatorg unit recycling_allocator.cpp)
mytest(unit_redirect_errorg unit redirect_error.cpp)
mytest(unit_registered_bufferg unit registered_buffer.cpp)
mytest(unit_serial_portg unit serial_port.cpp)
mytest(unit_serial_port_baseg unit serial_port_base.cpp)
mytest(unit_signal_setg unit signal_set.cpp)
mytest(unit_signal_set_baseg unit signal_set_base.cpp)
mytest(unit_socket_baseg unit socket_base.cpp)
mytest(unit_static_thread_poolg unit static_thread_pool.cpp)
mytest(unit_steady_timerg unit steady_timer.cpp)
mytest(unit_strandg unit strand.cpp)
mytest(unit_stream_fileg unit stream_file.cpp)
mytest(unit_streambufg unit streambuf.cpp)
mytest(unit_system_contextg unit system_context.cpp)
mytest(unit_system_executorg unit system_executor.cpp)
mytest(unit_system_timerg unit system_timer.cpp)
mytest(unit_this_corog unit this_coro.cpp)
mytest(unit_threadg unit thread.cpp)
mytest(unit_thread_poolg unit thread_pool.cpp)
mytest(unit_time_traitsg unit time_traits.cpp)
mytest(unit_ts_bufferg unit ts/buffer.cpp)
mytest(unit_ts_executorg unit ts/executor.cpp)
mytest(unit_ts_internetg unit ts/internet.cpp)
mytest(unit_ts_io_contextg unit ts/io_context.cpp)
mytest(unit_ts_netg unit ts/net.cpp)
mytest(unit_ts_netfwdg unit ts/netfwd.cpp)
mytest(unit_ts_socketg unit ts/socket.cpp)
mytest(unit_ts_timerg unit ts/timer.cpp)
mytest(unit_use_awaitableg unit use_awaitable.cpp)
mytest(unit_use_futureg unit use_future.cpp)
mytest(unit_uses_executorg unit uses_executor.cpp)
mytest(unit_wait_traitsg unit wait_traits.cpp)
mytest(unit_windows_basic_object_handleg unit windows/basic_object_handle.cpp)
mytest(unit_windows_basic_overlapped_handleg unit windows/basic_overlapped_handle.cpp)
mytest(unit_windows_basic_random_access_handleg unit windows/basic_random_access_handle.cpp)
mytest(unit_windows_basic_stream_handleg unit windows/basic_stream_handle.cpp)
mytest(unit_windows_object_handleg unit windows/object_handle.cpp)
mytest(unit_windows_overlapped_handleg unit windows/overlapped_handle.cpp)
mytest(unit_windows_overlapped_ptrg unit windows/overlapped_ptr.cpp)
mytest(unit_windows_random_access_handleg unit windows/random_access_handle.cpp)
mytest(unit_windows_stream_handleg unit windows/stream_handle.cpp)
mytest(unit_writable_pipeg unit writable_pipe.cpp)
mytest(unit_writeg unit write.cpp)
mytest(unit_write_atg unit write_at.cpp)
# if HAVE_CXX11
mytest(unit_experimental_basic_channelg unit experimental/basic_channel.cpp)
mytest(unit_experimental_basic_concurrent_channelg unit experimental/basic_concurrent_channel.cpp)
mytest(unit_experimental_channelg unit experimental/channel.cpp)
mytest(unit_experimental_channel_traitsg unit experimental/channel_traits.cpp)
mytest(unit_experimental_concurrent_channelg unit experimental/concurrent_channel.cpp)
# endif
# if HAVE_CXX20
# mytest(unit_experimental_promiseg unit experimental/promise.cpp)
# if HAVE_COROUTINES
# mytest(unit_experimental_awaitable_operatorsg unit experimental/awaitable_operators.cpp)
# mytest(unit_experimental_co_composedg unit experimental/co_composed.cpp)
# mytest(unit_experimental_coro_allocatorg unit experimental/coro/allocator.cpp)
# mytest(unit_experimental_coro_cancelg unit experimental/coro/cancel.cpp)
# mytest(unit_experimental_coro_co_spawng unit experimental/coro/co_spawn.cpp)
# mytest(unit_experimental_coro_exceptiong unit experimental/coro/exception.cpp)
# mytest(unit_experimental_coro_executorg unit experimental/coro/executor.cpp)
# mytest(unit_experimental_coro_partialg unit experimental/coro/partial.cpp)
# mytest(unit_experimental_coro_simple_testg unit experimental/coro/simple_test.cpp)
# mytest(unit_experimental_coro_stack_testg unit experimental/coro/stack_test.cpp)
# mytest(unit_experimental_coro_use_corog unit experimental/coro/use_coro.cpp)
# endif()
# endif()
# if HAVE_OPENSSL
# mytest(unit_ssl_context_baseg unit ssl/context_base.cpp)
# mytest(unit_ssl_contextg unit ssl/context.cpp)
# mytest(unit_ssl_errorg unit ssl/error.cpp)
# mytest(unit_ssl_stream_baseg unit ssl/stream_base.cpp)
# mytest(unit_ssl_host_name_verificationg unit ssl/host_name_verification.cpp)
# mytest(unit_ssl_rfc2818_verificationg unit ssl/rfc2818_verification.cpp)
# mytest(unit_ssl_streamg unit ssl/stream.cpp)
# endif()

# EXTRA_DIST = \
	# latency/allocator.hpp \
	# performance/handler_allocator.hpp \
	# unit/archetypes/async_ops.hpp \
	# unit/archetypes/async_result.hpp \
	# unit/archetypes/gettable_socket_option.hpp \
	# unit/archetypes/io_control_command.hpp \
	# unit/archetypes/settable_socket_option.hpp
